<!--
 * @Author: Hou 89426584@qq.com
 * @Date: 2023-11-14 11:05:34
 * @LastEditors: fangzepeng fangzp9669@qq.com
 * @LastEditTime: 2023-11-17 10:13:20
 * @FilePath: \updt-house-rent-front\pages\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="index">
    <div v-if="renderStatus" class="container">
      <ViewComponent />
      <MainPanel />
    </div>
  </div>
</template>

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator'
import MainPanel from '@/components/CPanel.vue'
import ViewComponent from '@/components/CView.vue'
import { setToken } from '@/assets/modules/auth'
@Component({
  name: 'IndexPage',
  components: { MainPanel, ViewComponent }
})
export default class extends Vue {
  renderStatus = false

  mounted() {
    const win: any = window
    const isUseToken = win.isUseToken
    // 开发环境isUseToken为true,测试为false
    if (isUseToken) {
      setToken(win.user.token)
      this.renderStatus = true
    } else {
      window.addEventListener(
        'message',
        (event) => {
          console.log(event.data)
          if (event.data.info == 'token') {
            localStorage.setItem('message', JSON.stringify(event.data))
            setToken(event.data.token)
            this.renderStatus = true
          }
        },
        false
      )
      const data = {
        info: 'mounted'
      }
      window.parent.postMessage(data, '*')
    }
    // const win:any = window;
    // setToken(win.user.token);
    // this.renderStatus = true;
    // window.addEventListener(
    //   "message",
    //   event => {
    //     console.log(event.data);
    //     if (event.data.info == "token") {
    //       localStorage.setItem("message", JSON.stringify(event.data));
    //       setToken(event.data.token);
    //       this.renderStatus = true;
    //     }
    //   },
    //   false
    // );
    // const data = {
    //   info: 'mounted'
    // }
    // window.parent.postMessage(data,'*');
  }
}
</script>

<style lang="scss" scoped>
.index,
.container {
  width: 100vw;
  height: 100vh;
  position: relative;
  background: #001022;
}
</style>
<style>
.el-select-dropdown__wrap {
  margin-bottom: 0px !important;
}
.el-scrollbar__wrap {
  overflow-x: hidden;
}
</style>
